﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StyleMVVM.DependencyInjection.Impl;

namespace StyleMVVM.DependencyInjection.Conditions
{
	/// <summary>
	/// Limits an export to only be used when the class it's being injected into has the specified attribute
	/// </summary>
	public class ExportWhenClassHasAttribute : Attribute, IExportConditionAttribute
	{
		private Type attributeType;

		/// <summary>
		/// Default constructor that takes an attribute type to filter on
		/// </summary>
		/// <param name="attributeType"></param>
		public ExportWhenClassHasAttribute(Type attributeType)
		{
			this.attributeType = attributeType;
		}

		/// <summary>
		/// Provide a condition for the type provided
		/// </summary>
		/// <param name="exportType"></param>
		/// <returns></returns>
		public IExportCondition ProvideCondition(Type exportType)
		{
			return new WhenClassHas(attributeType);
		}
	}
}